local addonName,ns = ...
local L = ns.L
local DB = ns.PlateColorDB
local SetLoaded--设置加载一次
ns.event("PLAYER_ENTERING_WORLD", function()
if SetLoaded then return end
SetLoaded = true
--分页2滚动框架
local ConFramescrollFrame2 = CreateFrame("ScrollFrame", nil, ns.tabframe2, "UIPanelScrollFrameTemplate")
ConFramescrollFrame2:SetPoint("TOPLEFT", ns.tabframe1, "TOPLEFT", 4, -5)
ConFramescrollFrame2:SetPoint("BOTTOMRIGHT", ns.tabframe1, "BOTTOMRIGHT", -30, 5)
--分页2滚动内容
local ConFrame2 = CreateFrame("Frame", nil, ConFramescrollFrame2)
ConFrame2:SetSize(670,480)
ConFramescrollFrame2:SetScrollChild(ConFrame2)
ns.Y[2] = 0	--设置起始位置

local ranks = ns.AddSetTiText(ConFrame2,2,"")
local ranktext = ConFrame2:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
ranktext:SetPoint("LEFT",ranks,"LEFT", -5, 5)
ranktext:SetText(L["颜色优先级"])
ranktext:SetFont(ns.fonts, 14, "OUTLINE")
ranktext:SetTextColor(1,1,1)


local npc = ns.AddSetTiText(ConFrame2,2,L["NPC列表"])
local npcRe = ns.AddfuncButton(ConFrame2,npc,L["重置NPC颜色"])
local npccolor1 = ns.AddSetColorF(ConFrame2,2,L["NPC1颜色"],L["NPC1颜色鼠标提示"],"npccolor1")
local npccolor2 = ns.AddSetColorF(ConFrame2,2,L["NPC2颜色"],L["NPC2颜色鼠标提示"],"npccolor2")
npcRe:HookScript("OnClick", function()
	PlateColorDB["npccolor1"] = DB["npccolor1"]
	PlateColorDB["npccolor2"] = DB["npccolor2"]
	npccolor1.color:SetColorTexture(DB["npccolor1"]["r"],DB["npccolor1"]["g"],DB["npccolor1"]["b"])
	npccolor2.color:SetColorTexture(DB["npccolor2"]["r"],DB["npccolor2"]["g"],DB["npccolor2"]["b"])
end)
local lesstiptext = L["自动判断斩杀线鼠标提示"].."\n"
for spell,value in pairs(ns.killSpellId) do
	if spell then
		lesstiptext = lesstiptext.."\n"..value.."%-".."|T"..ns.GetSpellIcon(spell)..":15|t "..ns.GetSpellName(spell).."="..spell
	end
end

local qt = ns.AddSetTiText(ConFrame2,2,L["其他颜色"])
local qtRe = ns.AddfuncButton(ConFrame2,qt,L["重置其他颜色"])
local autoLessHp = ns.AddSetClickB(ConFrame2,2,L["自动判断斩杀线"],lesstiptext,"autoLessHp")

--自动斩杀后面写上当前数值
local LessHptext = ConFrame2:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
LessHptext:SetPoint("LEFT", autoLessHp.check, "RIGHT", 10, 0)
LessHptext:SetFont(ns.fonts, 15, "OUTLINE")

--判断斩杀线,写上数值
local function killnowtext()
	ns.killvalue = PlateColorDB.setLessHp
	LessHptext:SetText(L["当前是下面的手动斩杀线"])
	for spell,value in pairs(ns.killSpellId) do
		if IsPlayerSpell(spell) and PlateColorDB.autoLessHp and value >= ns.killvalue then
			ns.killvalue = value
			LessHptext:SetText(L["当前"].."|T"..ns.GetSpellIcon(spell)..":15|t ".."|cff00FFFF"..ns.GetSpellName(spell).."|cff00FF00: "..ns.killvalue.."%")
		end
	end
	C_Timer.After(5,function()
		if type(PlayerFrame.PC) == "number" then
			ns.killvalue = PlayerFrame.PC
			LessHptext:SetText(L["当前是API"].." : |cff00FF00"..ns.killvalue.."%")
		end
	end)
end

autoLessHp.check:HookScript("OnClick", function()
	killnowtext()
end)
local talentupdate = CreateFrame("Frame")
talentupdate:RegisterEvent("PLAYER_TALENT_UPDATE")
talentupdate:RegisterEvent("SPELLS_CHANGED")
talentupdate:SetScript("OnEvent", function(self, event, ...)
	killnowtext()
end)

local setLessHp = ns.AddSetSlider(ConFrame2,2,L["手动斩杀线"],L["手动斩杀线鼠标提示"],0,100,1,"%d","setLessHp")
local lessHpLine = ns.AddSetClickB(ConFrame2,2,L["斩杀分割线"],L["斩杀分割线鼠标提示"],"lessHpLine")
local useLessHp = ns.AddSetClickB(ConFrame2,2,L["启用斩杀颜色"],L["启用斩杀颜色鼠标提示"],"useLessHp")
local lessHp = ns.AddSetColorF(ConFrame2,2,L["斩杀颜色"],L["斩杀颜色鼠标提示"],"lessHp")
local myTarget = ns.AddSetClickB(ConFrame2,2,L["当前目标变色"],L["当前目标变色鼠标提示"],"myTarget")
local myTargetColor = ns.AddSetColorF(ConFrame2,2,L["当前目标颜色"],L["当前目标颜色鼠标提示"],"myTargetColor")
local myFocus = ns.AddSetClickB(ConFrame2,2,L["焦点变色"],L["焦点变色鼠标提示"],"myFocus")
local myFocusColor = ns.AddSetColorF(ConFrame2,2,L["焦点颜色"],L["焦点颜色鼠标提示"],"myFocusColor")
local allColor = ns.AddSetColorF(ConFrame2,2,L["全局颜色"],L["全局颜色鼠标提示"],"allColor")
qtRe:HookScript("OnClick", function()
	PlateColorDB["lessHp"] = DB["lessHp"]
	PlateColorDB["myTargetColor"] = DB["myTargetColor"]
	PlateColorDB["myFocusColor"] = DB["myFocusColor"]
	PlateColorDB["allColor"] = DB["allColor"]
	myTargetColor.color:SetColorTexture(DB["myTargetColor"]["r"],DB["myTargetColor"]["g"],DB["myTargetColor"]["b"])
	myFocusColor.color:SetColorTexture(DB["myFocusColor"]["r"],DB["myFocusColor"]["g"],DB["myFocusColor"]["b"])
	lessHp.color:SetColorTexture(DB["lessHp"]["r"],DB["lessHp"]["g"],DB["lessHp"]["b"])
	allColor.color:SetColorTexture(DB["allColor"]["r"],DB["allColor"]["g"],DB["allColor"]["b"])
end)

local threatColors = ns.AddSetTiText(ConFrame2,2,L["仇恨"])
local threatColorsRe = ns.AddfuncButton(ConFrame2,threatColors,L["重置仇恨颜色"])
local usethreatColors = ns.AddSetClickB(ConFrame2,2,L["启用仇恨变色"],L["启用仇恨变色鼠标提示"],"threatColor")
local noThreatColor = ns.AddSetColorF(ConFrame2,2,L["低仇恨"],L["低仇恨鼠标提示"],"noThreatColor")
local highThreatColor = ns.AddSetColorF(ConFrame2,2,L["高仇恨"],L["高仇恨鼠标提示"],"highThreatColor")
local myThreatColor = ns.AddSetColorF(ConFrame2,2,L["仇恨是你"],L["仇恨是你鼠标提示"],"myThreatColor")
local lowThreatColor = ns.AddSetColorF(ConFrame2,2,L["仇恨不稳"],L["仇恨不稳鼠标提示"],"lowThreatColor")
threatColorsRe:HookScript("OnClick", function()
	PlateColorDB["noThreatColor"] = DB["noThreatColor"]
	PlateColorDB["highThreatColor"] = DB["highThreatColor"]
	PlateColorDB["myThreatColor"] = DB["myThreatColor"]
	PlateColorDB["lowThreatColor"] = DB["lowThreatColor"]
	noThreatColor.color:SetColorTexture(DB["noThreatColor"]["r"],DB["noThreatColor"]["g"],DB["noThreatColor"]["b"])
	highThreatColor.color:SetColorTexture(DB["highThreatColor"]["r"],DB["highThreatColor"]["g"],DB["highThreatColor"]["b"])
	myThreatColor.color:SetColorTexture(DB["myThreatColor"]["r"],DB["myThreatColor"]["g"],DB["myThreatColor"]["b"])
	lowThreatColor.color:SetColorTexture(DB["lowThreatColor"]["r"],DB["lowThreatColor"]["g"],DB["lowThreatColor"]["b"])
end)


local isthreatColors = ns.AddSetTiText(ConFrame2,2,L["坦克仇恨"])
local isthreatColorRe = ns.AddfuncButton(ConFrame2,isthreatColors,L["重置坦克颜色"])
local useisthreatColors = ns.AddSetClickB(ConFrame2,2,L["启用坦克仇恨变色"],L["启用坦克仇恨变色鼠标提示"],"TANKthreatColor")
local TnoThreatColor = ns.AddSetColorF(ConFrame2,2,L["坦克低仇恨"],L["坦克低仇恨鼠标提示"],"TANKnoThreatColor")
local ThighThreatColor = ns.AddSetColorF(ConFrame2,2,L["坦克高仇恨"],L["坦克高仇恨鼠标提示"],"TANKhighThreatColor")
local TmyThreatColor = ns.AddSetColorF(ConFrame2,2,L["坦克仇恨是你"],L["坦克仇恨是你鼠标提示"],"TANKmyhreatColor")
local TlowThreatColor = ns.AddSetColorF(ConFrame2,2,L["坦克仇恨不稳"],L["坦克仇恨不稳鼠标提示"],"TANKlowThreatColor")
isthreatColorRe:HookScript("OnClick", function()
	PlateColorDB["TANKnoThreatColor"] = DB["TANKnoThreatColor"]
	PlateColorDB["TANKhighThreatColor"] = DB["TANKhighThreatColor"]
	PlateColorDB["TANKmyhreatColor"] = DB["TANKmyhreatColor"]
	PlateColorDB["TANKlowThreatColor"] = DB["TANKlowThreatColor"]
	TnoThreatColor.color:SetColorTexture(DB["TANKnoThreatColor"]["r"],DB["noThreatColor"]["g"],DB["TANKnoThreatColor"]["b"])
	ThighThreatColor.color:SetColorTexture(DB["TANKhighThreatColor"]["r"],DB["highThreatColor"]["g"],DB["TANKhighThreatColor"]["b"])
	TmyThreatColor.color:SetColorTexture(DB["TANKmyhreatColor"]["r"],DB["myThreatColor"]["g"],DB["TANKmyhreatColor"]["b"])
	TlowThreatColor.color:SetColorTexture(DB["TANKlowThreatColor"]["r"],DB["TANKlowThreatColor"]["g"],DB["TANKlowThreatColor"]["b"])
end)

local advancedColors = ns.AddSetTiText(ConFrame2,2,L["进阶自定义"])
local PCBARCOLOR = ns.AddSetColorF(ConFrame2,2,L["进阶血条颜色"],L["进阶血条颜色鼠标提示"],"PCBARCOLOR")

end)